﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using TalentPools.Model;
using TalentPools.DAL;

namespace TalentPools.BLL
{
    public class Company_LoginManager
    {
        #region 企业用户注册
        /// <summary>
        /// 注册企业用户
        /// </summary>
        /// <param name="company"></param>
        /// <returns></returns>
        public bool RegCompanyLoginInfo(Company_Login company)
        {
            return new Company_LoginService().InsertCompany_Login(company);
        }
        #endregion

        #region 判断用户名是否存在
        /// <summary>
        /// 判断用户名是否存在
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public object GetUserCount(string username)
        {
            return new Company_LoginService().GetUserCount(username);

        }
        public object GetUserCount(string loginName, string pwd,ref string msg)
        {
            object val= new Company_LoginService().GetUserCount(loginName, pwd);
            if (Convert.ToInt32(val)==1)
            {
                msg = new Company_LoginService().GetUserState(loginName);
                if (msg!="")
                {
                    return 0;
                }
            }
            return val;
        }
        #endregion

        #region 分页查询
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        public DataSet GetLoginPage(int pageIndex, int pageSize, string where)
        {
            return new Company_LoginService().GetLoginPage(pageIndex, pageSize, where);
        }
        /// <summary>
        /// 查询记录数
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public int GetLoginCount(string where)
        {
            return new Company_LoginService().GetLoginCount(where);
        }
        #endregion

        #region 删除操作
        public bool DeleteLogin(int id)
        {
            return new Company_LoginService().DeleteLogin(id);
        }
        #endregion

        #region 修改密码
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool EditPwd(string username, string password)
        {
            return new Company_LoginService().EditPwd(username, password);
        }
        /// <summary>
        /// 查询旧密码
        /// </summary>
        /// <param name="companyName"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public bool CheckPwd(string companyName, string pwd)
        {
            string oldpwd = new Company_LoginService().CheckPwd(companyName);
            if (pwd==oldpwd)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        #endregion

        #region 更新注册信息状态

        /// <summary>
        /// 更改VIP状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public bool UpdateState(int id, bool state)
        {
            return new Company_LoginService().UpdateState(id, state);
        }
        /// <summary>
        /// 更改推荐状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="t"></param>
        /// <returns></returns>
        public bool UpdateTj(int id, bool t)
        {
            return new Company_LoginService().UpdateTj(id, t);
        }
        /// <summary>
        /// 审核企业
        /// </summary>
        /// <param name="id"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public bool UpdatePast(int id, bool b)
        {
            return new Company_LoginService().UpdatePast(id, b);
        }
        #endregion

        #region 查看企业是否是付费用户
        /// <summary>
        /// 查看企业是否是付费用户
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public string CheckIsVip(string username)
        {
            return new Company_LoginService().CheckVip(username);
        }
        #endregion
    }
}
